# Set include directories for this subdirectory
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/../include
)

# Core library
add_library(ObfuscatorCore STATIC
    core/ObfuscatorEngine.cpp
    core/ClassObfuscator.cpp
    core/PropertyObfuscator.cpp
    core/MethodObfuscator.cpp
    core/TrashCodeGenerator.cpp
    core/CodeValidator.cpp
    core/WhitelistManager.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/ObfuscatorEngine.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/ClassObfuscator.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/PropertyObfuscator.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/MethodObfuscator.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/TrashCodeGenerator.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/CodeValidator.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/core/WhitelistManager.h
)
set_target_properties(ObfuscatorCore PROPERTIES AUTOMOC ON)

# UI library
add_library(ObfuscatorUI STATIC
    ui/MainWindow.cpp
    ui/CustomSplitter.cpp
    ui/CustomScrollView.cpp
    ui/ConfigPanel.cpp
    ui/ProjectTreeWidget.cpp
    ui/HistoryWidget.cpp
    ui/PreviewDialog.cpp
    ui/CodeEditor.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/MainWindow.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/CustomSplitter.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/CustomScrollView.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/ConfigPanel.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/ProjectTreeWidget.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/HistoryWidget.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/PreviewDialog.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/ui/CodeEditor.h
)
set_target_properties(ObfuscatorUI PROPERTIES AUTOMOC ON)

# Database library
add_library(ObfuscatorDB STATIC
    database/DatabaseManager.cpp
    database/HistoryManager.cpp
    database/MappingStorage.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/database/DatabaseManager.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/database/HistoryManager.h
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/database/MappingStorage.h
)
set_target_properties(ObfuscatorDB PROPERTIES AUTOMOC ON)

# Utils library
add_library(ObfuscatorUtils STATIC
    utils/FileManager.cpp
    utils/Logger.cpp
    utils/StringUtils.cpp
    utils/RandomGenerator.cpp
    utils/Theme.cpp
)

# Set include directories for each library
target_include_directories(ObfuscatorCore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories(ObfuscatorUI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories(ObfuscatorDB PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_include_directories(ObfuscatorUtils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)

# Link Qt libraries to each component
target_link_libraries(ObfuscatorCore Qt6::Core Qt6::Concurrent Qt6::Sql)
target_link_libraries(ObfuscatorUI Qt6::Core Qt6::Widgets ObfuscatorCore ObfuscatorDB)
target_link_libraries(ObfuscatorDB Qt6::Core Qt6::Sql)
target_link_libraries(ObfuscatorUtils Qt6::Core)